﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:uc="clr-namespace:SqlMiM.Common.UserControls;assembly=SqlMiM.Common"             
    xmlns:conv="clr-namespace:SqlMiM.Common.Converters;assembly=SqlMiM.Common"
    xmlns:vsm="clr-namespace:System.Windows;assembly=WPFToolkit" 
    xmlns:local="clr-namespace:SqlMiM.SqlServer.ServerStats"
    x:Class="SqlMiM.SqlServer.ServerStats.View"
    xmlns:src="clr-namespace:SqlMiM.Common.Controls;assembly=SqlMiM.Common"
    xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"    
    xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:chartingprimitives="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    
    Loaded="UserControl_Loaded"
    mc:Ignorable="d"
    >

    <UserControl.Resources>

        <ResourceDictionary>


            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/SqlMiM.Common;component/Resources/ControlsTheme.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <conv:BooleanToVisibilityConverter x:Key="VisibleIfTrue" Inverted="True" Not="False"    />
            <conv:BooleanToVisibilityConverter x:Key="VisibleIfNotTrue" Inverted="True" Not="True"    />
            <conv:ReverseBooleanConverter x:Key="ReverseBooleanConverter" />

            <!--  charting:Chart  -->
            <Style TargetType="charting:Chart" x:Key="ChartMimumStyle">
                <Setter Property="IsTabStop" Value="False" />
                <Setter Property="SnapsToDevicePixels" Value="True" />
                <Setter Property="StylePalette">
                    <Setter.Value>
                        <datavis:StylePalette>
                            <!-- Indigo -->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFA9A3BD" />
                                            <GradientStop Color="#FF382C6C" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!-- Magenta -->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFB1A1B1" />
                                            <GradientStop Color="#FF50224F" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!--Red-->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFFBB7B5" />
                                            <GradientStop Color="#FF702828" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!--Blue-->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFB9D6F7" />
                                            <GradientStop Color="#FF284B70" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!-- ColorLight Green -->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFB8C0AC" />
                                            <GradientStop Color="#FF5F7143" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!-- Yellow -->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFFDE79C" />
                                            <GradientStop Color="#FFF6BC0C" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!-- ColorDark Green -->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FF9DC2B3" />
                                            <GradientStop Color="#FF1D7554" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!--Gray Shade-->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFB5B5B5" />
                                            <GradientStop Color="#FF4C4C4C" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!--Blue-->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FF98C1DC" />
                                            <GradientStop Color="#FF0271AE" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!-- Brown -->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFC1C0AE" />
                                            <GradientStop Color="#FF706E41" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!--Cyan-->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFADBDC0" />
                                            <GradientStop Color="#FF446A73" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!-- Special Blue -->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FF2F8CE2" />
                                            <GradientStop Color="#FF0C3E69" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!--Gray Shade 2-->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFDCDCDC" />
                                            <GradientStop Color="#FF757575" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!--Gray Shade 3-->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFF4F4F4" />
                                            <GradientStop Color="#FFB7B7B7" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!--Gray Shade 4-->
                            <Style TargetType="Control">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819" />
                                                    <TranslateTransform X="-0.425" Y="-0.486" />
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFF4F4F4" />
                                            <GradientStop Color="#FFA3A3A3" Offset="1" />
                                        </RadialGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </datavis:StylePalette>
                    </Setter.Value>
                </Setter>
                <Setter Property="PlotAreaStyle">
                    <Setter.Value>
                        <Style TargetType="Grid">
                            <Setter Property="Background" Value="Transparent" >
                            </Setter>
                        </Style>
                    </Setter.Value>
                </Setter>
                <Setter Property="ChartAreaStyle">
                    <Setter.Value>
                        <Style TargetType="Panel">
                            <Setter Property="MinWidth" Value="100" />
                            <Setter Property="MinHeight" Value="100" />
                        </Style>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="charting:Chart">
                            <Grid Grid.Row="1" >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>

                                <datavis:Legend x:Name="Legend" Title="{TemplateBinding LegendTitle}" Style="{TemplateBinding LegendStyle}" Grid.Column="1" />
                                <chartingprimitives:EdgePanel x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}">
                                    <Grid Canvas.ZIndex="-1" Style="{TemplateBinding PlotAreaStyle}" />
                                </chartingprimitives:EdgePanel>
                            </Grid>

                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <!--  datavis:Legend  -->
            <Style TargetType="datavis:Legend" x:Key="LegendMimumStyle">
                <Setter Property="IsTabStop" Value="False" />
                <Setter Property="Foreground" Value="{DynamicResource Foreground}" />
                <Setter Property="TitleStyle">
                    <Setter.Value>
                        <Style TargetType="datavis:Title">
                            <Setter Property="Margin" Value="0,5,0,10" />
                            <Setter Property="FontWeight" Value="Bold" />
                            <Setter Property="HorizontalAlignment" Value="Center" />
                        </Style>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="datavis:Legend">
                            <Border Padding="2">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition />
                                    </Grid.RowDefinitions>
                                    <datavis:Title Grid.Row="0" Content="{TemplateBinding Title}" Style="{TemplateBinding TitleStyle}" />
                                    <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" BorderThickness="0" Padding="0" IsTabStop="False">
                                        <StackPanel Grid.Column="1" x:Name="LegendItemsArea" Margin="10,0,10,10" />
                                    </ScrollViewer>
                                </Grid>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>



        </ResourceDictionary>
    </UserControl.Resources>


    <StackPanel Orientation="Vertical" DataContext="{Binding ServerInfo}" >

        <Grid  >
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition MinHeight="300" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="300" />
                <ColumnDefinition MinWidth="300"  />
            </Grid.ColumnDefinitions>

            <ContentControl Margin="10,10,10,0" VerticalAlignment="Top" MinWidth="250" Grid.Column="0" >
                <ContentControl.Content>

                    <StackPanel Orientation="Vertical" >
                        <ContentControl Style="{DynamicResource TitleContentControlStyle}">
                            <ContentControl.Content>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="/SqlMiM.SqlServer;component/Images/server_chart.png"  Margin="5,1,1,1" Width="16"
                                   HorizontalAlignment="Left" VerticalAlignment="Center" Stretch="Uniform" x:Name="img" />
                                    <Label Foreground="{DynamicResource Foreground}" FontWeight="Bold"  Margin="5,0,0,0" Content="Server Details"
                                   HorizontalAlignment="Left" VerticalAlignment="Center" />
                                </StackPanel>
                            </ContentControl.Content>
                        </ContentControl>

                        <Grid Margin="5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition  />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>



                            <TextBlock Grid.Column="0" Grid.Row="0" Text="Server Name" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding ServerName}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="1" Text="Server Startup" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding LoginUpTime, StringFormat={}{0:dd/MM/yyyy HH:mm:ss}}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="2" Text="Server Edition" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding Edition}" Margin="0,8,0,0"  Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="3" Text="Server Product Level" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding ProductLevel}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="4" Text="Server Engine Edition" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding EngineEdition}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="5" Text="Server Version" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="5" Text="{Binding VersionString}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="6" Text="Machine Net Name" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="6" Text="{Binding NetName}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />
                        </Grid>

                    </StackPanel>
                </ContentControl.Content>
            </ContentControl>

            <ContentControl Margin="10,10,10,0" VerticalAlignment="Top" MinWidth="250" Grid.Column="1">
                <ContentControl.Content>
                    <StackPanel Orientation="Vertical" >

                        <ContentControl Style="{DynamicResource TitleContentControlStyle}">
                            <ContentControl.Content>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="/SqlMiM.SqlServer;component/Images/server_chart.png"  Margin="5,1,1,1" Width="16"
                                   HorizontalAlignment="Left" VerticalAlignment="Center" Stretch="Uniform" />
                                    <Label Foreground="{DynamicResource Foreground}" FontWeight="Bold"  Margin="5,0,0,0" Content="Server Informations"
                                   HorizontalAlignment="Left" VerticalAlignment="Center" />
                                </StackPanel>
                            </ContentControl.Content>
                        </ContentControl>

                        <Grid Margin="5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition  />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>


                            <TextBlock Grid.Column="0" Grid.Row="0" Text="Total Server Memory" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding TotalServerMemory}" Margin="0,8,0,0"  Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="1" Text="Total Databases" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding DatabasesCount}" Margin="0,8,0,0"  Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="2" Text="Cluster" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding IsClustered}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="3" Text="Full Text Installed" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding IsFullTextInstalled}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="4" Text="CLR" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding BuildClrVersionString}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="5" Text="Collation" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="5" Text="{Binding Collation}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="6" Text="Resource Last Update Date" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="6" Text="{Binding ResourceLastUpdateDateTime, StringFormat={}{0:dd/MM/yyyy HH:mm:ss}}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                        </Grid>

                    </StackPanel>
                </ContentControl.Content>
            </ContentControl>

            <ContentControl Margin="10,10,10,0" VerticalAlignment="Top" MinWidth="250" Grid.Column="0" Grid.Row="1" >
                <ContentControl.Content>

                    <StackPanel Orientation="Vertical" >

                        <ContentControl Style="{DynamicResource TitleContentControlStyle}">
                            <ContentControl.Content>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="/SqlMiM.SqlServer;component/Images/server_chart.png"  Margin="5,1,1,1" Width="16"
                                   HorizontalAlignment="Left" VerticalAlignment="Center" Stretch="Uniform" />
                                    <Label Foreground="{DynamicResource Foreground}" FontWeight="Bold"  Margin="5,0,0,0" Content="Activity Details"
                                   HorizontalAlignment="Left" VerticalAlignment="Center" />
                                </StackPanel>
                            </ContentControl.Content>
                        </ContentControl>


                        <Grid Margin="5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition  />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>



                            <TextBlock Grid.Column="0" Grid.Row="0" Text="Active Sessions" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding ActiveSessionsCount}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="1" Text="Active Transactions" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding ActiveTransactionCount}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />
                        </Grid>

                    </StackPanel>
                </ContentControl.Content>
            </ContentControl>

            <ContentControl Margin="10,10,10,0" VerticalAlignment="Top" MinWidth="250" Grid.Column="1" Grid.Row="1" >
                <ContentControl.Content>

                    <StackPanel Orientation="Vertical" >
                        <ContentControl Style="{DynamicResource TitleContentControlStyle}">
                            <ContentControl.Content>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="/SqlMiM.SqlServer;component/Images/server_chart.png"  Margin="5,1,1,1" Width="16"
                                   HorizontalAlignment="Left" VerticalAlignment="Center" Stretch="Uniform" />
                                    <Label Foreground="{DynamicResource Foreground}" FontWeight="Bold"  Margin="5,0,0,0" Content="Connections Details"
                                   HorizontalAlignment="Left" VerticalAlignment="Center" />
                                </StackPanel>
                            </ContentControl.Content>
                        </ContentControl>

                        <Grid Margin="5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition  />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>



                            <TextBlock Grid.Column="0" Grid.Row="0" Text="User Connections" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding UserConnections}" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                            <TextBlock Grid.Column="0" Grid.Row="1" Text="Logical Connections" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" />
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding LogicalConnections}" Margin="0,8,0,0"  Foreground="{DynamicResource Foreground}" FontWeight="Bold" HorizontalAlignment="Right" />

                        </Grid>

                    </StackPanel>
                </ContentControl.Content>
            </ContentControl>

            <ContentControl Margin="10,10,10,0" VerticalAlignment="Top" Grid.Row="2" Grid.ColumnSpan="2" MinHeight="300"  >
                <ContentControl.Content>

                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*"  />
                        </Grid.RowDefinitions>

                        <ContentControl Style="{DynamicResource TitleContentControlStyle}">
                            <ContentControl.Content>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="/SqlMiM.SqlServer;component/Images/server_chart.png"  Margin="5,1,1,1" Width="16"
                                   HorizontalAlignment="Left" VerticalAlignment="Center" Stretch="Uniform" />
                                    <Label Foreground="{DynamicResource Foreground}" FontWeight="Bold" Margin="5,0,0,0" Content="Total Input / Output Stats"
                                   HorizontalAlignment="Left" VerticalAlignment="Center" />
                                </StackPanel>
                            </ContentControl.Content>
                        </ContentControl>

                        <StackPanel Orientation="Horizontal"  Grid.Row="1">
                            
                            <DockPanel LastChildFill="True">
                                <TextBlock DockPanel.Dock="Top" Text="Total Input Output on all databases" Margin="40,8,0,10" Foreground="{DynamicResource Foreground}" 
                                           FontWeight="Bold" HorizontalAlignment="Left" />
                                <charting:Chart  Width="400"  Style="{StaticResource ChartMimumStyle}" Title="Total Io" LegendTitle="Databases" LegendStyle="{StaticResource LegendMimumStyle}" >
                                    <charting:Chart.Series>
                                        <charting:PieSeries ItemsSource="{Binding InputsOutuputs}" Width="220" Height="220" 
                                                DependentValueBinding="{Binding TotalIO}" IndependentValueBinding="{Binding DatabaseName}" />
                                    </charting:Chart.Series>
                                </charting:Chart>
                            </DockPanel>

                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="Total reads on all databases" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" 
                                           FontWeight="Bold" HorizontalAlignment="Center" />
                                <charting:Chart Style="{StaticResource ChartMimumStyle}" Width="120" Height="120"
                                        Title="Total Reads" Margin="8,0,0,0" VerticalAlignment="Center" LegendTitle="Databases"
                                        HorizontalAlignment="Left">
                                    <charting:Chart.Series>
                                        <charting:PieSeries ItemsSource="{Binding InputsOutuputs}"  Width="100" Height="100" 
                                                DependentValueBinding="{Binding TotalReads}" IndependentValueBinding="{Binding DatabaseName}" />
                                    </charting:Chart.Series>
                                    <charting:Chart.Template>
                                        <ControlTemplate TargetType="charting:Chart">
                                                <chartingprimitives:EdgePanel x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}">
                                                    <Grid Canvas.ZIndex="-1" Style="{TemplateBinding PlotAreaStyle}" />
                                                </chartingprimitives:EdgePanel>
                                        </ControlTemplate>
                                    </charting:Chart.Template>
                                </charting:Chart>

                                <TextBlock Text="Total writes on all databases" Margin="0,8,0,0" Foreground="{DynamicResource Foreground}" 
                                           FontWeight="Bold" HorizontalAlignment="Center" />

                                <charting:Chart Style="{StaticResource ChartMimumStyle}"  Width="120" Height="120"
                                        Title="Total Writes" Margin="8,0,0,0" VerticalAlignment="Center"  LegendTitle="Databases"
                                        HorizontalAlignment="Left">
                                    <charting:Chart.Series>
                                        <charting:PieSeries ItemsSource="{Binding InputsOutuputs}"  Width="100" Height="100" 
                                                DependentValueBinding="{Binding TotalWrites}" IndependentValueBinding="{Binding DatabaseName}" />
                                    </charting:Chart.Series>
                                    <charting:Chart.Template>
                                        <ControlTemplate TargetType="charting:Chart">
                                            <chartingprimitives:EdgePanel x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}">
                                                <Grid Canvas.ZIndex="-1" Style="{TemplateBinding PlotAreaStyle}" />
                                            </chartingprimitives:EdgePanel>
                                        </ControlTemplate>
                                    </charting:Chart.Template>
                                </charting:Chart>
                            </StackPanel>


                        </StackPanel>

                    </Grid>
                </ContentControl.Content>
            </ContentControl>



        </Grid>

    </StackPanel>

</UserControl>
